package com.isunland.managesystem.ui;

import android.support.v4.app.Fragment;
import com.isunland.managesystem.entity.EmployeeLoanContent;
import com.isunland.managesystem.entity.TravelListContent;

public class AddTravelReimburseListActivity extends SingleFragmentActivity {
  public static final String EXTRA_TYPE = "com.isunland.managesystem.ui.EXTRA_TYPE";
  private EmployeeLoanContent mEmployeeLoanContent;
  // 判断是差旅明细详情
  public static final int EXTRA_SHOWCONTENTTYPE = 0;
  // 判断是添加差旅明细详情
  public static final int EXTRA_ADDCONTENTTYPE = 1;
  // 判断修改差旅明细详情
  public static final int EXTRA_EDITCONTENTTYPE = 2;
  private android.support.v4.app.Fragment mFragment;
  private TravelListContent item;

  //差旅详情、添加、修改都是一个Activity
  @Override protected Fragment createFragment() {
    //根据type判断是添加还是现实详情
    int type = getIntent().getIntExtra(EXTRA_TYPE, 0);

    switch (type) {
      //详情界面
      case EXTRA_SHOWCONTENTTYPE:
        //接收传过来的content
        item = (TravelListContent) getIntent().getSerializableExtra(
            ShowTravelReimburseListDetailFragment.EXTRA_TRAVELLIST_CONTENT);
        mEmployeeLoanContent = (EmployeeLoanContent) getIntent().getSerializableExtra(
            ShowTravelReimburseListDetailFragment.EXTRA_EMPLOYEELOAN_CONTENT);
        mFragment = ShowTravelReimburseListDetailFragment.newInstance(item, mEmployeeLoanContent);
        break;
      //添加明细
      case EXTRA_ADDCONTENTTYPE:
        mEmployeeLoanContent = (EmployeeLoanContent) getIntent().getSerializableExtra(
            AddTravelReimburseListDetailFragment.EXTRA_TRAVELREIMBURSE_CONTENT);
        mFragment = AddTravelReimburseListDetailFragment.newInstance(mEmployeeLoanContent);
        break;
      //修改
      case EXTRA_EDITCONTENTTYPE:
        //接收传过来的content
        item = (TravelListContent) getIntent().getSerializableExtra(
            EditTravelReimburseListDetailFragment.EXTRA_TRAVELLIST_CONTENT);
        mFragment = EditTravelReimburseListDetailFragment.newInstance(item);
        break;
      default:
        break;
    }

    return mFragment;
  }
}
